<% layout('/layouts/default.html', {title: '会员管理', libs: ['validate','fileupload']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-trophy"></i> ${text(leaguer.isNewRecord ? '新增会员' : '编辑会员')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${leaguer}" action="${ctx}/fl/leaguer/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="id"/>

				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required ">*</span> ${text('会员手机')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:input path="cellphone" maxlength="200" class="form-control required phone"
									remote="${ctx}/fl/leaguer/checkLeaguerCellphone?oldLeaguerCellphone=${leaguer.cellphone}"
									data-msg-remote="${text('会员手机已存在')}"/>
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required ">*</span> ${text('姓名')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:input path="name" maxlength="200" class="form-control required"/>
							</div>
						</div>
					</div>
					
				</div>
				<% if (!leaguer.isNewRecord){ %>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('密码')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								${leaguer.password}
							</div>
						</div>
					</div>
					
				</div>
			<% } %>	
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('身份证号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:input path="idNumber" maxlength="20" minlength="1" class="form-control "/>
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('性别')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:select path="sex" dictType="sys_user_sex" blankOption="true" class="form-control "/>
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required ">*</span> ${text('出生日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:input path="birthday" readonly="true" maxlength="20" class="form-control Wdate"
									dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>					
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('归属企业')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:select path="enterprise.id" items="${enterpriseList}" itemLabel="name" itemValue="id" blankOption="true" class="form-control"/>			
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
							  ${text('保险公司')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
									<#form:select path="insurer" dictType="fl_insurer" blankOption="true" class="form-control"/>			
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
							  ${text('保险卡号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
									<#form:input path="insuranceNumber" class="form-control"/>			
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
							  <span class="required ">*</span> ${text('证件类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
									<#form:select path="certificateType" dictType="fl_certificate_type" blankOption="true" class="form-control required"/>			
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
							  ${text('倾向语言')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
									<#form:select path="language" dictType="fl_language" blankOption="true" class="form-control"/>			
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
							  ${text('真实姓名')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
									<#form:input path="realName" class="form-control"/>			
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
							  ${text('是否有过敏史')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
									<#form:select path="hasAllergicHistory" dictType="sys_yes_no" blankOption="true" class="form-control"/>			
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
							  ${text('过敏史')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
									<#form:input path="allergicHistory" class="form-control"/>			
							</div>
						</div>
					</div>
					
				</div>

				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-9">
						<% if (hasPermi('fl:leaguer:edit')){ %>
							<button type="button" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#btnSubmit").click(function () {
	var certificateType = $("#certificateType").val();
	var idNumber = $("#idNumber").val().length;
	if(certificateType == 1 && idNumber != 18 && idNumber != 0){
			js.showMessage("身份证必须是18位的！！");
			$("#idNumber").focus();
      return;
	}

	$('#inputForm').submit();
});

$("#inputForm").validate({
	submitHandler: function(form){
		
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>
